home *** CD-ROM | disk | FTP | other *** search
/ The Trig Explorer / The Trig Explorer.iso / pc / explorer / ex_funct.dxr / 00031.ls < prev    next >
Encoding:
Text File  |  1997-07-22  |  1.7 KB  |  60 lines

  1. on enterFrame
  2.   global x, y, r, theta
  3.   puppetSprite(13, 1)
  4.   put " " into field "Answer1"
  5.   put " " into field "Answer2"
  6.   updateStage()
  7.   set x to random(400) - 200
  8.   if x = 0 then
  9.     set x to random(200)
  10.   end if
  11.   put x into field "X"
  12.   set y to random(400) - 200
  13.   if y = 0 then
  14.     set y to random(200)
  15.   end if
  16.   put y into field "Y"
  17.   set the floatPrecision to 5
  18.   set r to float(sqrt(float(x * x) + float(y * y)))
  19.   set theta to float(atan(float(y) / float(x)))
  20.   if (x > 0) and (y < 0) then
  21.     set theta to (2.0 * PI) + theta
  22.   end if
  23.   if (x < 0) and (y > 0) then
  24.     set theta to PI + theta
  25.   end if
  26.   if (x < 0) and (y < 0) then
  27.     set theta to PI + theta
  28.   end if
  29.   set the floatPrecision to 1
  30.   put r into field "R"
  31.   if random(10) > 5 then
  32.     set the floatPrecision to 1
  33.     put theta * 180.0 / PI into field "Theta"
  34.     set the hilite of cast "Degrees" to 1
  35.     set the hilite of cast "Radians" to 0
  36.     set the castNum of sprite 13 to 50
  37.   else
  38.     set the floatPrecision to 2
  39.     put theta into field "Theta"
  40.     set the castNum of sprite 13 to 51
  41.     set the hilite of cast "Degrees" to 0
  42.     set the hilite of cast "Radians" to 1
  43.   end if
  44.   updateStage()
  45.   put cos(theta) into field "Cos"
  46.   put sin(theta) into field "Sin"
  47.   set the textSize of field "Answer1" to 32
  48.   set the textSize of field "Answer2" to 32
  49.   set the textSize of field "X" to 32
  50.   set the textSize of field "Y" to 32
  51.   set the textSize of field "R" to 32
  52.   set the textSize of field "Theta" to 32
  53.   set the textStyle of field "Answer1" to "bold"
  54.   set the textStyle of field "Answer2" to "bold"
  55.   set the textStyle of field "X" to "bold"
  56.   set the textStyle of field "Y" to "bold"
  57.   set the textStyle of field "R" to "bold"
  58.   set the textStyle of field "Theta" to "bold"
  59. end
  60.